#include<queue>
#include<cstring>
#include <iostream>
#define MaxN 201
using namespace std;
const int direction[4][2] = { 1,0,-1,0,0,-1,0,1 };
int m, n, x, y;
int visited[MaxN][MaxN];
char map[MaxN][MaxN];
struct Node
{
	int x, y, time;
	Node():x(0),y(0),time(0){}
	Node(int x, int y, int time) :x(x), y(y), time(time){}
	Node(const Node & node):x(node.x),y(node.y),time(node.time){}		
};
int sol()
{
	Node now(x,y,0);	
	queue<Node>q;		
	q.push(now); 
	visited[x][y] = 1;
	while (!q.empty())
	{
		now = q.front();
		q.pop();
		if (map[now.x][now.y] == 'r')
			return now.time;
		for (int i = 0; i<4; i++)
		{
			Node next = now;
			next.x  += direction[i][0];
			next.y  += direction[i][1];
			if (next.x >= 0 && next.x<n&&
				next.y >= 0 && next.y<m&&
				map[next.x][next.y] != '#' && !visited[next.x][next.y])
			{
				if (map[next.x][next.y] == 'x')
					next.time = now.time + 2;
				else 
					next.time = now.time + 1;
				visited[next.x][next.y] = 1;
				q.push(next);
			}
		}
	}
	return -1;
}
int main()
{
	
	while (cin>>n>>m)
	{
		if (n == 0 && m == 0)
			break;
		cin.get();
		for (int i = 0; i<n; i++)
		{
			for (int j = 0; j<m; j++)
			{
				cin >> map[i][j];
				if (map[i][j] == 'a')
				{
					x = i; 
					y = j;
				}
			}
			cin.get();
		}		
		memset(visited, 0, sizeof(visited));
		int ans = sol();
		if (ans != -1)
			cout << ans << endl;
		else
			cout << "Poor ANGEL has to stay in the prison all his life.\n";
	}
	return 0;
}